import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../common/utils/constants.dart';

import 'index.dart';

class StartPage extends GetView<StartController> {
  const StartPage({super.key});

  // 主视图
  Widget _buildView() {
    return Stack(
      fit: StackFit.expand,
      children: [
        // 背景图
        Image.asset(Images.startBg, fit: BoxFit.cover),

        // 内容层
        Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Spacer(flex: 2),

            // Logo 动画
            AnimatedBuilder(
              animation: controller.logoAnimationController,
              builder: (context, child) {
                return Transform.scale(
                  scale:
                      controller.logoAnimation.value *
                      controller.scaleAnimation.value,
                  child: Opacity(
                    opacity: controller.fadeInAnimation.value,
                    child: child,
                  ),
                );
              },
              child: Image.asset(Images.startLogo, width: 160, height: 160),
            ),

            const SizedBox(height: 30),

            // 应用名称
            AnimatedBuilder(
              animation: controller.logoAnimationController,
              builder: (context, child) {
                return Opacity(
                  opacity: controller.fadeInAnimation.value,
                  child: child,
                );
              },
              child: Text(
                Constants.appName,
                style: const TextStyle(
                  color: Colors.white,
                  fontSize: 42,
                  fontWeight: FontWeight.bold,
                  letterSpacing: 2,
                ),
              ),
            ),

            const Spacer(flex: 3),
          ],
        ),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<StartController>(
      init: StartController(),
      id: "start",
      builder: (_) {
        return Scaffold(body: _buildView());
      },
    );
  }
}
